December 1995

Backing up and restoring file systems on Solaris 2.x

One of the most important jobs of a system administrator, backing-up and restoring filesystems, should be practiced on a weekly basis. Backing up files means making copies of them, usually on removable media such as tapes, as protection against original files being lost or damaged. Regularly scheduled backups are essential in case of serious hardware failures or other disasters.

When you back up file systems according to a schedule, you have the assurance that you can restore any files on your system to a reasonably recent state. In addition, you may want to back up file systems to transport them from one system to another or to archive them so that you can remove or alter files that remain on the system.

In this article, we'll discuss using ufsdump and ufsrestore to back up and restore filesystems on your Solaris 2.x equipment. We'll also discuss planning a backup schedule for your system.

Getting started

When planning a backup schedule, you should consider some of the following questions:

All of these considerations can affect when and what you back up on your system. As a general rule, you might want to consider using the tape archive utility tar for smaller file backups. When you need to back up entire file systems, you'll probably want to use ufsdump.

Backing up with ufsdump

The ufsdump utility, located in the /usr/sbin directory, uses command-line options to determine the type of backup you want to perform. Using the syntax

ufsdump [options] [arguments] files_to_dump

you can create simple shell scripts to perform specific backup functions on your Solaris system.

In the options field, you can specify the parameters. The most common parameter used is dump level. By assigning a dump level from 0-9, you can plan incremental backups (or dumps). To perform a full backup of a file system, use dump level 0. Once you perform a dump level 0 or complete backup, you can then use higher dump levels for backing up files that changed since the last lower numbered dump.

For example, on Monday you perform a backup using dump level 1. If you perform a backup the following day with a higher dump level (2-9), the only files dumped will be those that changed since the last lower dump level performed the day before. Only when you specify a complete file system dump with a dump level 0 will the entire filesystem be backed up. You can see other ufsdump options in Table A.

TABLE A

Option Definition

a archive_file Archive a dump table of contents in the specified archive_file for use with ufsrestore.

b factor Specify the blocking factor for the tape writes

c Set the dump defaults for a cartridge tape

d bpi Configure the tape density (bytes-per-inch). This is not normally required

D Dump to diskette

f dump_file Use the name specified by dump_file rather than a standard tape device for the dump

l Configure for autoloading. When ufsdump reaches the end of the tape, take the drive offline for up to two minutes to allow for tape autoloading.

n Notify all users in the group sys. This is not normally required.

o Take the drive offline when the end of the media is reached. This prevents another process from overwriting a dump.

s size Specify the size of the volume being dumped to

S Determine the amount of space needed for a dump without actually performing it

t tracks Specify the number of tracks for a cartridge tape

u Update the dump record in the file /etc/dumpdates

v Verify the contents on the media with the contents on the source drive

w List the file systems that havenít been backed up within a day

W List information on all file systems and their recent dump date information

You can specify these option with ufsdump.

Using ufsdump with a QIC-150 cartridge tape

To get an idea about how you perform a backup with ufsdump, we'll use one of the most commonly available tape drives, the QIC-150. In order to complete a full backup on a file system with ufsdump, be sure that all users are logged out and that the system is in single-user mode.

Once you've brought the system down to single-user mode and inserted a tape in the drive, enter the command

ufsdump 0cuf /dev/rmt/0 c0t0d0s7

at the command prompt. The 0 option specifies a level 0 or complete backup. The c option specifies a cartridge tape. The u option updates the dump record in the /etc/dumpdates file. The device /dev/rmt/0 specifies the default unit to dump files. The last option, c0t0d0s7, specifies the raw disk slice for the file system you want to back up.

If the dump requires more than one tape, the ufsdump command tells you when to put in a new tape. You should label and date each tape as you remove the cartridges. Be sure to number them as well when performing a multiple-tape backup.

Once you perform a complete backup and write to the dump record, you can then perform incremental backups using different dump levels. This is extremely important to remember when planning your backup schedule since incremental backups take less time than full ones.

Restoring a backed-up file system with ufsrestore

The ufsrestore command copies files from backups created with ufsdump into the current working directory. You can restore an entire file system from a level 0 dump or restore one or more files from any dump tape. When you restore a file with ufsrestore, you'll find that the owner name, last modification time, and permissions will be intact.

Before you begin restoring files from a dump, you must first determine which backup tapes you'll need. When restoring an entire file system, you'll always need the most recent level 0 backup tape and any subsequent incremental backup tapes for the restore procedure.

To re-create the filesystem we backed up in our example with ufsdump and restore the files from the tape, follow these instructions: First, become the superuser and bring the system down to single-user mode with the command

init s

If the file system you backed up became damaged in some way, you may want to re-create it. If you choose to do this, the file system on your disk will be WIPED CLEAN!

To re-create a new file system, make sure that the file system you're restoring is unmounted using the umount command. Next, type the command

newfs /dev/rdsk/c09t0d0s7

and press [Enter]. This wipes clean the raw device file for that disk slice and rebuilds the file system. Then use the mount command to remount the block device at the mount point you specify.

Once you remount the filesystem, change directories to the mount point and run the command

ufsrestore rvf /dev/rmt/0h

This instruction will restore the file system that we backed up in our example using ufsdump.

Restoring individual files

When restoring individual files and directories, it's a good idea to restore them to a temporary directory such as /var/tmp. After you restore the files, you can then verify them before overwriting any files in their original locations.

If you don't know the locations of files you want to restore from a given tape, you can browse the tape using ufsrestore. First, become the superuser root and place the tape in the drive. Change directories to your desired temporary directory and then run the command

ufsrestore if /dev/rmt/0

You should see some tape information and then the prompt

ufsrestore>

Now you can list the files on your tape using the ls command. You can also change directories on the tape.

As you browse the contents of the tape, you can restore directories and filenames using the command

ufsrestore> add filename

Likewise, you can remove a file or directory from your list to be restored with the command

ufsrestore> remove filename

When you've completed your list, enter the command extract. The ufsrestore utility will then ask you which volume number to use. If you have only one volume on the tape, type 1 and press [Enter]. The files and directories in your list will then be extracted and restored into your current working directory. When you've finished, simply type quit to exit.

Conclusion

Backups are essential for data security. By following a backup schedule, you can rest easy in the knowledge that no matter what the crisis, your data is safe. In this article, we've discussed how to use the ufsdump and ufsrestore utilities with Solaris 2.x.


[Return to Index for Inside Solaris - December Issue]

Copyright (c) 1995 The Cobb Group, a division of Ziff-Davis Publishing Company. All rights reserved.

Reproduction in whole or in part in any form or medium without express written permission of Ziff-Davis

Publishing Company is prohibited. The Cobb Group and The Cobb Group logo are trademarks of

Ziff-Davis Publishing Company.

Inside Solaris is a publication of The Cobb Group.
1-800-223-8720